package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * 读取文本文件
 */
public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        File file=new File("./src/main/java/io/Test.java");
        FileInputStream fis=new FileInputStream(file);
        long len=file.length();
        byte[] bytes=new byte[(int)len];

        fis.read(bytes);
        String xin=new String(bytes, StandardCharsets.UTF_8);
        System.out.println(xin);
        fis.close();
    }
}
